'=======================================
' 执行所有测试 case
'=======================================
Private Sub test_ALL_case()
    ' CurrentDimensionLevel 测试
    test_CurrentDimensionLevel
    ' CurrentDimensionSize 测试
    test_CurrentDimensionSize
    ' NextDimensionSize 测试
    test_NextDimensionSize
    ' ParentMatrix 测试
    test_ParentMatrix
    ' HasNextDimensionObject 测试
    test_HasNextDimensionObject
    ' getSubDimensionByParams 测试
    test_sub_dimension1
    test_sub_dimension2
    test_sub_dimension3
    ' getData 测试 obj_nothing
    test_getData_obj_nothing
    ' getPrimitiveData 测试
    test_getPrimitiveData
    ' getObjData 测试
    test_getObjData
End Sub
'=======================================
' 各方法的测试 case
'=======================================
' CurrentDimensionLevel 测试
Private Sub test_CurrentDimensionLevel()
    Dim m As ArrayMatrix
    Set m = New ArrayMatrix
    m.InitBySizeArray Array(6, 5, 4, 3)
    
    Dim d As ArrayMatrixDimension
    Set d = m.getSubDimensionByParams(1, 2)
    
    Debug.Assert d.CurrentDimensionLevel = 1
End Sub

' CurrentDimensionSize 测试
Private Sub test_CurrentDimensionSize()
    Dim m As ArrayMatrix
    Set m = New ArrayMatrix
    m.InitBySizeArray Array(6, 5, 4, 3)
    
    Dim d As ArrayMatrixDimension
    Set d = m.getSubDimensionByParams(1, 2)
    
    Debug.Assert d.CurrentDimensionSize = 5
End Sub

' NextDimensionSize 测试
Private Sub test_NextDimensionSize()
    Dim m As ArrayMatrix
    Set m = New ArrayMatrix
    m.InitBySizeArray Array(6, 5, 4, 3)
    
    Dim d As ArrayMatrixDimension
    Set d = m.getSubDimensionByParams(1, 2)
    
    Debug.Assert d.NextDimensionSize = 4
End Sub


' ParentMatrix 测试
Private Sub test_ParentMatrix()
    Dim m As ArrayMatrix
    Set m = New ArrayMatrix
    m.InitBySizeArray Array(6, 5, 4, 3)

    Dim d As ArrayMatrixDimension
    Set d = m.getSubDimensionByParams(1, 2, 3)
    
    Debug.Assert d.ParentMatrix Is m
End Sub

' HasNextDimensionObject 测试
Private Sub test_HasNextDimensionObject()
    Dim m As ArrayMatrix
    Set m = New ArrayMatrix
    m.InitBySizeArray Array(6, 5, 4, 3)

    Dim d As ArrayMatrixDimension
    Set d = m.getSubDimensionByParams(1, 2, 3)
    Debug.Assert d.HasNextDimensionObject = False
    
    Set d = m.getSubDimensionByParams(1, 2)
    Debug.Assert d.HasNextDimensionObject = True
End Sub

' getSubDimensionByParams 测试
Private Sub test_sub_dimension1()
    Dim m As ArrayMatrix
    Set m = New ArrayMatrix
    m.Init 6, 5, 4, 3
    
    m.setData "abc", 1, 2, 3, 2
    
    Dim d As ArrayMatrixDimension
    Set d = m.getSubDimensionByParams(1, 2)
    
    Debug.Assert d.getData(3, 2) = "abc"
End Sub

Private Sub test_sub_dimension2()
    Dim m As ArrayMatrix
    Set m = New ArrayMatrix
    m.Init 6, 5, 4, 3, 3, 4
    
    m.setData "abc", 1, 2, 3, 2, 1, 3
    
    Dim d As ArrayMatrixDimension
    Set d = m.getSubDimensionByParams(1, 2)
    
    Dim d2 As ArrayMatrixDimension
    Set d2 = d.getSubDimensionByParams(3, 2)
    
    Debug.Assert d2.getData(1, 3) = "abc"
End Sub

Private Sub test_sub_dimension3()
    Dim m As ArrayMatrix
    Set m = New ArrayMatrix
    m.Init 6, 5, 4, 3, 3, 4
    
    m.setData "abc", 1, 2, 3, 2, 1, 3
    
    Dim d As ArrayMatrixDimension
    Set d = m.getSubDimensionByParams(1, 2)
    
    Dim d2 As ArrayMatrixDimension
    Set d2 = d.getNextDimension(3)
    
    Debug.Assert d2.getData(2, 1, 3) = "abc"
    
    d2.setData "xyz", 2, 1, 2
    Debug.Assert d2.getData(2, 1, 2) = "xyz"
End Sub

' getData 测试 obj_nothing
Private Sub test_getData_obj_nothing()
    Dim m As ArrayMatrix
    Set m = New ArrayMatrix
    m.Init 6, 5, 4, 3
    
    Dim d As ArrayMatrixDimension
    Set d = m.getSubDimensionByParams(1, 2)
    
On Error GoTo catch:
    Dim result As Object
    Set result = d.getData(3, 2)
    GoTo continue
catch:
    If Err.Number = 424 Then
        Set result = Nothing
    Else
        Err.Raise Err.Number, Description:=Err.Description
    End If
continue:
    
    Debug.Assert result Is Nothing
End Sub

' getPrimitiveData 测试
Private Sub test_getPrimitiveData()
    Dim m As ArrayMatrix
    Set m = New ArrayMatrix
    m.Init 6, 5, 4, 3
    
    Dim d As ArrayMatrixDimension
    Set d = m.getSubDimensionByParams(1, 2)
    
    Dim result1 As Variant
    result1 = d.getPrimitiveData(3, 2)
    Debug.Assert IsEmpty(result1)
    
    Dim result2 As String
    result2 = d.getPrimitiveData(3, 2)
    Debug.Assert result2 = ""
    
    d.setData "xyz", 3, 2
    result2 = d.getPrimitiveData(3, 2)
    Debug.Assert result2 = "xyz"
End Sub

' getObjData 测试
Private Sub test_getObjData()
    Dim m As ArrayMatrix
    Set m = New ArrayMatrix
    m.Init 6, 5, 4, 3
    
    Dim d As ArrayMatrixDimension
    Set d = m.getSubDimensionByParams(1, 2)
    
    Dim result1 As Object
    Set result1 = d.getObjData(3, 2)
    Debug.Assert result1 Is Nothing
    
    Dim c As Collection
    Set c = New Collection
    c.Add "xyz"
    d.setData c, 3, 2
    
    Dim cx As Collection
    Set cx = d.getObjData(3, 2)
    Debug.Assert cx Is c
End Sub

